<template>
	<view class="p-20">
		<view class="flex flex-column grid-gap-10">
			<view class="p-10 round-8 border-hint flex flex-x-space-between flex-y-center" v-for="(item,index) in list"
				:key='index' @click="jump(item)">
				<view class="flex flex-y-center">
					<image :src="item.image" class="w-80 h-80 round-6"></image>
					<view class="flex flex-column grid-gap-10 ml-10">
						<text class="text-primary fs-16 fw-600">{{item.name}}</text>
						<text class="text-hint fs-12">{{item.desc}}</text>
					</view>
				</view>
				<uv-icon name='tags' size="30"></uv-icon>
			</view>
		</view>
	</view>
</template>

<script setup>
	import { ref } from 'vue';
	import { onLoad } from '@dcloudio/uni-app'
	import { $http } from '../../utils';
	const list = ref([])
	onLoad(() => {
		getList()
	})
	const getList = () => {
		let str = 'weixin'
		// #ifdef MP-TOUTIAO
		str = 'douyin'
		// #endif
		$http.get('Jump/getList', { types: str }).then(res => {
			list.value = res.data
		})
	}

	const jump = (item) => {
		// #ifdef MP-TOUTIAO
		tt.navigateToMiniProgram({
			appId: item.appid,
			path: item.path,
			fail(err) {
				uni.showModal({
					title: '错误提示',
					content: "跳转失败" + err.errMsg,
					showCancel: false
				})
			}
		})
		// #endif
		// #ifdef MP-WEIXIN
		wx.navigateToMiniProgram({
			appId: item.appid,
			path: item.path,
			shortLink: item.link,
			success(res) {
				console.log('成功', res)
			},
			fail(err) {
				uni.showModal({
					title: '错误提示',
					content: "跳转失败" + err.errMsg,
					showCancel: false
				})
			}
		})
		// #endif
	}
</script>

<style>

</style>